<?php 
	namespace Admin\Controller;

	class MbookController extends AdminController
	{
		
		public function index()
		{
			// 把传过来的值变为整型	
			$mid = (int)I()['mid'];

			// var_dump(I()['mid']) ;
			$mbook = M('mbook')->where("mid=$mid")->select();
			$this->assign('mbook',$mbook);
			$this->display();
		}

		public function add()
		{
			$more = M('book');
			$mid = I('mid');
			// echo "<pre>";
			// var_dump($mid);
			$book = $more->select();
			$this->assign('mid',$mid);
			$this->assign('book',$book);
			$this->display();
		}

		// 执行添加
		public function doadd()
		{
			$mk = M('mbook');
			// echo "<pre>";
			// var_dump(I());
			// exit;
			if($mk->add(I())>0){
				$this->success('添加成功',U('Mbook/index',array('mid'=>I('mid'))));
			}else{
				$this->error('添加失败');
			}
		}

		public function delajax(){
			
			$id = I('id');
			$mid = I('mid');
	        $del = M('mbook');

	        $result = $del->where("id = $id")->delete();

	        if($result){
	           	$this->ajaxReturn($result);        
        	}
        
    	}

		
	}